/*
 * @Description: 
 * @Version: 0.0.1
 * @Autor: zhj1214
 * @Date: 2021-11-16 09:50:18
 * @LastEditors: zhj1214
 * @LastEditTime: 2021-11-22 17:05:30
 */
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import App from './App.vue'
import routes from './router'
import store from './store'
import './public-path';

let router = null;
let instance = null;
function render(props = {}) {
    const { container } = props;
    console.log('process.env.BASE_URL',props)
    router = createRouter({
        // base: window.__POWERED_BY_QIANKUN__ ? '/wqd/vue/' : '/',
        // base:'/wqd/vue/',
        // base:'/vue/',
        mode: 'history',
        history: createWebHistory('/wqd/vue/'),
        routes
    })

    instance = createApp(App).use(store).use(router)
    console.log('instance',instance)
    instance.mount(container ? container.querySelector('#app') : '#app')
}
// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
    render();
}

instance && (() => instance.config.productionTip = false)


export async function bootstrap() {
    console.log('[vue] vue app bootstraped');
}
export async function mount(props) {
    console.log('[vue] props from main framework', props);
    render(props);
}
export async function unmount() {
    console.log(instance,'--instance--')
    instance.unmount();
    instance = null;
    router = null;
}